<!DOCTYPE html>
<html>

	<head>
		<meta content="application/xhtml+xml;charset=UTF-8" http-equiv="Content-Type">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
		<title>我的速运-注册</title>

		<link rel="stylesheet" type="text/css" href="css/styleloginsign.css">
		<link rel="stylesheet" type="text/css" href="css/bootstrap/bootstrap.min.css">

		<script type="text/javascript" src="js/jquery.min.js"></script>
		<script type="text/javascript" src="js/bootstrap.min.js"></script>
		<script type="text/javascript" src="js/self/effect.js"></script>

		<script type="text/javascript" src="js/angular.min.js"></script>

		<script type="text/javascript">
			$(function() {
				$("#checkPassword").blur(function() {
					var checkPassword = $(this).val();
					var password = $("#password").val();
					if(checkPassword != password) {
						$("#password_msg").html("两次输入的密码不一致");
						$("#submitBtn").attr("href", "javascript:void(0)")
					} else {
						$("#password_msg").empty();
						$("#submitBtn").attr("href", "javascript:$('#signupForm').submit()")
					}
				})
			})
		</script>

		<!--[if IE]>
    <script  type="text/javascript" src="js/html5.js"></script>
    <script  type="text/javascript" src="js/respond.min.js"></script>
    <![endif]-->
	</head>

	<body>
		<!--head-->
		<div class="loginnav">
			<nav class="navbar navbar-default">
				<div class="container">
					<div class="navbar-header">
						<a class="navbar-brand" href="#"><img src="images/icon/logo.png"></a>
						<span class="logintitle">用户注册</span>
					</div>
				</div>

			</nav>
		</div>
		<div class="container">
			<!--mainsignup-->
			<section class="mainsign">
				<div class="headnav">

				</div>
				<!--ng-app定义模块及其作用域,ng-controller定义控制器-->
				<div class="signup" ng-app="signupApp" ng-controller="signupCtrl">
					<div class="col-md-9 signupbox">
						<form id="signupForm" method="post" action="signup_addCustomer.action" class="form col-md-6">
							<div class=" form-group">
								<label for="inputaccount" class="col-sm-3 control-label"><b>*</b>手机号</label>
								<div class="col-sm-8">
									<input type="text" name="telephone" class="form-control" ng-model="telephone" id="inputaccount" placeholder="请输入手机号">
								</div>
							</div>
							<div class="form-group">
								<label for="inputaccount" class="col-sm-3 control-label"><b>*</b>验证码</label>
								<div class="col-sm-5">
									<input type="text" name="checkCode" class="form-control" id="inputaccount" placeholder="请输入验证码">
								</div>
								<div class="col-sm-3 song">
									<!--ng-bind == {{}} 用于数据显示,ng-click = '***()'定义事件-->
									<a ng-bind="btnMsg" ng-click="getCheckCode(telephone)" class="btn btn-default">获取验证码</a>
								</div>

							</div>
							<div class="form-group">
								<label for="inputaccount" class="col-sm-3 control-label"><b>*</b>密码</label>
								<div class="col-sm-8">
									<input name="password" type="password" class="form-control" id="password" placeholder="6-16位数字或英文字母">
									<p class="text-right grey">安全强度：*****</p>
								</div>

							</div>

							<div class="form-group">
								<label for="inputaccount" class="col-sm-3 control-label"><b>*</b>确认密码</label>
								<div class="col-sm-8">
									<span><input type="password" class="form-control" id="checkPassword" placeholder="6-16位数字或英文字母">
									<p style="color: red;" id="password_msg"></p>
									</span>
								</div>
							</div>
							<div class="form-group">
								<label for="inputaccount" class="col-sm-3 control-label"><b>*</b>绑定邮箱</label>
								<div class="col-sm-8">
									<input type="email" name="email" class="form-control" id="inputemail" placeholder="请输入需要绑定的邮箱">
								</div>
							</div>
							<div class="form-group">
								<div class="col-sm-offset-3 col-sm-8 song">
									<div class="checkbox">
										<label>
      <input type="checkbox"> 查看并同意<a href="#"> 《速运快递服务协议》</a>
    </label>
									</div>

								</div>
							</div>
							<div class="form-group signbtn">
								<div class="col-sm-offset-3 col-sm-8 song">
									<a id="submitBtn" class="btn btn-danger" onclick="" href="javascript:$('#signupForm').submit()">注册</a>
								</div>
							</div>

						</form>

					</div>
					<div class="col-md-3 introbox">
						<div class="signintro">
							<h5 class="redtext">注册成为速运会员，您可以享受更多的服务！</h5>
							<ul>
								<li class="list-group">积分奖励，电子运单专享特权</li>
								<li class="list-group">快速理赔，保价优惠</li>
								<li class="list-group">大陆偏远地区附加费减免</li>
								<li class="list-group">快件路由订阅，快件信息管理，批量下单</li>

							</ul>
						</div>

					</div>
				</div>
			</section>

		</div>

		<!--foot-->
		<footer>
			<section class="copyright size12">
				<div class="container">
					<p class="text-center">地址：北京市昌平区建材城西路金燕龙办公楼一层 邮编：100096 电话：400-618-4000 传真：010-82935100 </p>
					<p class="text-center">京ICP备08001421号京公网安备110108007702</p>
				</div>
			</section>
		</footer>
		<script type="text/javascript">
			//初始化模块
			var signupApp = angular.module("signupApp", []);
			//定义模块控制器
			signupApp.controller("signupCtrl", ["$scope", "$http", function($scope, $http) {
				//按钮初始显示内容
				$scope.btnMsg = "获取验证码";
				//定义标记用于确定按钮是否能点击
				var flag = true;
				//定义倒计时时间,被定时器控制一直--,如果值小于0就重置按钮
				var time = 60;
				//定义循环计时器
				var secondInterval;
				//定义点击时间
				$scope.getCheckCode = function(telephone) {
					//判断标记,确定是否能够点击
					if(flag == false) {
						return;
					};
					//1.发送验证码给客户
					var regex = /^1[34578]\d{9}$/;
					if(regex.test(telephone)) {
						$http({
							method: 'post',
							url: 'signup_checkCode.action',
							params: {
								'telephone': telephone
							}
						}).success(function(data, status, headers, config) {
							alert("发送成功,请查看手机")
						}).error(function(data, status, headers, config) {
							alert("发送失败,请联系管理员")
						});
					} else {
						alert("手机号码有误,请重新输入");
						return;
					}
					//2.显示倒计时按钮,60s后允许重发
					//修改标记值
					flag = false;
					//循环计时器,前面参数是方法,后面参数是毫秒值
					secondInterval = setInterval(function() {
						//倒计时值已确定判断循环了多少次
						if(time < 0) {
							$scope.btnMsg = "重发验证码";
							$scope.$digest();
							time = 60;
							flag = true;
							clearInterval(secondInterval);
							secondInterval = undefined;
						} else {
							$scope.btnMsg = time + "秒后重发";
							$scope.$digest();
							time--;
						}
					}, 1000);
				}
			}]);
		</script>
	</body>

</html>